<?php
/**
 * Created by PhpStorm.
 * User: home
 * Date: 2019/2/23
 * Time: 19:02
 */
/**
 * 显示错误提示页
 * @param {string} $message 要显示的消息
 */
function showMessage($message)
{
    echo <<<EOT

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>错误页面</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<style>
.panel{
    border: solid 1px #ddd;
    border-radius: 4px;
    padding: 20px;;
}
.alert {
    border-radius: 5px;
    padding: 15px;
    border: solid 1px #ddd;
    background-color: #f5f5f5;
}
.s{
    top: -60px;
    position: relative;
}
.pt-title{
font-size: 20px;
}
</style>
</head>

<body>
<div class="container" style=" margin-top:8%;"> 
   <div class="panel mt-lg-5">
      <div class="text-center">
        <p class="pt-title">{$message}</p>
        <div class="">
            <a href="index.php" class="btn btn-danger" style="background-color: #f60;border: none;font-size: 14px;">重新查询</a>
        </div> 
      </div>
      <div class="s"> 
            <div class="float-left">
                <img src="http://www.pintuer.com/images/ds-1.gif">
                <div class="alert"> 卧X！系统出错了！ </div>
            </div>
            <div class="float-right">
               <img src="http://www.pintuer.com/images/ds-2.png" width="260"> 
            </div>
          </div>
   </div> 
</div>
</body>
</html>
EOT;
    die();
}

function queryStudentInfo($student_no)
{
    try{
      $pdo = new PDO('mysql:host=192.168.10.123;port=13306;dbname=data', 'root', '123456',
  [PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8']);
    $query = $pdo->query('select * from student_info where student_no=' . $student_no);
    return $query->fetch(PDO::FETCH_ASSOC);
  }catch(Exception $e){
    return null;
  }
}
function queryStudentScore($student_no)
{
    try{
    $pdo = new PDO('mysql:host=192.168.10.123;port=13306;dbname=data', 'root', '123456',
  [PDO::MYSQL_ATTR_INIT_COMMAND => 'set names utf8']);
    $query = $pdo->query('select * from student_score where student_no=' . $student_no);
    return $query->fetchAll(PDO::FETCH_ASSOC);
  }catch(Exception $e){
    return null;
  }
}